package com.nl.pulsardemo.admin;

import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.common.policies.data.ClusterData;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author : ZhaoY
 * @description :pulsarAdmin用户
 * @date : 2021-02-04 15:44
 **/
public class PulsarAdminDemo {
    public static void main(String[] args) {
        String url = "pulsar://10.1.8.68:6650,10.1.8.64:6650,10.1.8.69:6650";
// Pass auth-plugin class fully-qualified name if Pulsar-security enabled
// Pass auth-param if auth-plugin class requires it
        boolean useTls = false;
        boolean tlsAllowInsecureConnection = false;
        String tlsTrustCertsFilePath = null;
        try {

            PulsarAdmin admin = PulsarAdmin.builder()
                    .serviceHttpUrl(url)
                    .connectionTimeout(3, TimeUnit.SECONDS)
                    .allowTlsInsecureConnection(true)
//                    .authentication("com.org.MyAuthPluginClass", "param1:value1")
                    .build();
            try  {
                ClusterData cluster = admin.clusters().getCluster("pulsar-cluster-zk");
                List<String> clusters = admin.clusters().getClusters();
                System.out.println("over");
            } catch (PulsarAdminException e) {
                e.printStackTrace();
            }

        } catch (PulsarClientException e) {
            e.printStackTrace();
        }
    }
}
